package com.mrx.giteewebhook.controller;

import com.mrx.giteewebhook.constants.GiteeWebhookConstants;
import com.mrx.giteewebhook.model.request.push.PushRequest;
import com.mrx.giteewebhook.service.GiteeWebhookService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mr.X
 * @since 2024-03-08 13:36
 **/
@RestController
@RequestMapping("/webhook")
public class GiteeWebhookController {

    @Resource
    private GiteeWebhookService giteeWebhookService;

    @PostMapping("/onPush")
    public Object onPush(
            @RequestBody PushRequest pushRequest,
            @RequestHeader(GiteeWebhookConstants.X_GITEE_TOKEN) String sign,
            @RequestHeader(GiteeWebhookConstants.X_GITEE_TIMESTAMP) Long timestamp
    ) {
        return giteeWebhookService.onPush(pushRequest, sign, timestamp);
    }

}
